package com.hancher.plugins.hrasmlog;

import android.content.res.Resources;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class LogUtil {
    public static void click(View v) {
        if (v == null) {
            Log.d("LogUtil", "全埋点(点击):v is null");
            return;
        }
        StringBuffer stringBuffer = new StringBuffer();
        String name = v.getClass().getName();
        try {
            name = name.substring(name.lastIndexOf('.') + 1);
        } catch (Exception e) {

        }
        stringBuffer.append("类名:").append(name);
        if (v instanceof TextView) {
            TextView b = (TextView) v;
            stringBuffer.append(", 文本框内容:").append(b.getText().toString());
        }
        int id = v.getId();
        if (id != View.NO_ID) {
            final Resources r = v.getResources();
            if (id > 0 /*&& Resources.resourceHasPackage(id)*/ && r != null) {
                try {
                    stringBuffer.append(", 视图:").append("R." + r.getResourceTypeName(id) + "." + r.getResourceEntryName(id));
                } catch (Resources.NotFoundException e) {
                }
            }
        }
        Log.d("LogUtil", "全埋点(点击):" + stringBuffer.toString());
    }
}
